package com.github.data_manage.domain.po

import cn.idev.excel.annotation.ExcelIgnore
import cn.idev.excel.annotation.ExcelProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.databind.deser.std.StringDeserializer
import com.github.data_manage.util.ArrayToStringDeSerialize
import com.github.data_manage.util.LocalDateConvert
import com.github.data_manage.util.StringToArraySerialize
import jakarta.persistence.*
import jakarta.validation.constraints.NotBlank
import java.io.Serializable
import java.math.BigDecimal
import java.time.LocalDate
import java.time.LocalDateTime
import java.util.*


/**
 *
 * 基金表
 *
 *@author CHN
 *@since 2024-08-10 15:00
 */
@Entity
@Table(name = "t_fund")
open class Fund : Serializable {

    // 基金名ID
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "fund_id")
    @ExcelIgnore
    open var fundId: Int? = null

    // 基金名称
    @NotBlank(message = "基金名称不能为空")
    @ExcelProperty("基金名称", index = 0)
    open var fundName: String? = null

    @ExcelIgnore
    open var fundShortName: String? = null

    // 成立日期
    @ExcelProperty("成立日期", index = 1)
    open var createDate: String? = null

    // ticker
    @ExcelProperty("ticker", index = 2)
    open var ticker: String? = null

    // 公司ID
    @ExcelIgnore
    open var companyId: Int? = null

    // 公司名称
    @ExcelProperty("公司名称", index = 3)
    open var companyName: String? = null

    // 公司地址
    @ExcelIgnore
    open var companyAddress: String? = null

    //"基金管理规模")
    @ExcelProperty("基金管理规模", index = 4)
    open var aum: BigDecimal? = null

    //"策略AUM")
    @ExcelProperty("策略AUM", index = 5)
    open var strategyAum: String? = null

    //"主要策略")
    @ExcelProperty("主要策略", index = 6)
    open var mainStrategy: String? = null

    //"行业分布")
    @ExcelProperty("行业分布", index = 7)
    open var industryDistribution: String? = null

    //"地区分布")
    @ExcelProperty("地区分布", index = 8)
    open var geographicalDistribution: String? = null

    //"基金简介")
    @ExcelProperty("基金简介", index = 9)
    open var fundDescription: String? = null

    //"平均仓位")
    @ExcelProperty("平均仓位", index = 10)
    open var averagePosition: String? = null

    //"平均净仓位")
    @ExcelProperty("平均净仓位", index = 11)
    open var averageNetPosition: String? = null

    //"组合名字数")
    @ExcelProperty("组合名字数", index = 12)
    open var totalNumberOfHoldings: String? = null

    @ExcelProperty("多仓数量", index = 13)
    open var morePosition: String? = null

    @ExcelProperty("空仓数量", index = 14)
    open var emptyPosition: String? = null

    @ExcelProperty("Top仓位", index = 15)
    open var topPosition: String? = null

    @ExcelProperty("Top5仓位", index = 16)
    open var top5Position: String? = null

    @ExcelProperty("Top10仓位", index = 17)
    open var top10Position: String? = null

    //"组合换手率")
    @ExcelProperty("组合换手率", index = 18)
    open var turnoverRate: String? = null

    //"投资者结构")
    @ExcelProperty("投资者结构", index = 19)
    open var investorComposition: String? = null

    // 年化回报
    @ExcelIgnore
    @Column(columnDefinition = "decimal(38,2) null ")
    open var yearNav: BigDecimal? = null

    // 年化标准差
    @ExcelIgnore
    @Column(columnDefinition = "decimal(38,2) null ")
    open var yearStandardDeviation: BigDecimal? = null

    // 基金特点
    @ExcelProperty("基金特点", index = 20)
    @JsonDeserialize(using = StringDeserializer::class)
    @Column(columnDefinition = "longtext")
    open var fundFeatures: String? = null

    // 经纪商
    @ExcelProperty("经纪商", index = 21)
    open var fundBrokers: String? = null

    // 审计
    @ExcelProperty("审计", index = 22)
    open var fundAudit: String? = null

    // Admin
    @ExcelProperty("Admin", index = 23)
    open var fundAdmin: String? = null

    // 律师
    @ExcelProperty("律师", index = 24)
    open var fundLayer: String? = null

    @ExcelProperty("更新时间", index = 25)
    open var updateTime: LocalDateTime? = null

    @ExcelProperty("InternalAum", index = 26)
    open var internalAum: String? = null

    @JsonSerialize(using = StringToArraySerialize::class)
    @JsonDeserialize(using = ArrayToStringDeSerialize::class)
    @Column(columnDefinition = "varchar(510)")
//    @ExcelProperty("主策略", index = 26)
    open var parentAum: String? = null

    //    @ExcelProperty("子策略", index = 26)
    @JsonSerialize(using = StringToArraySerialize::class)
    @JsonDeserialize(using = ArrayToStringDeSerialize::class)
    @Column(columnDefinition = "varchar(510)")
    open var childAum: String? = null

    //"基金简介")
    @ExcelProperty("其他描述", index = 27)
    @Column(columnDefinition = "longtext")
    open var otherDescription: String? = null

    @ExcelProperty("是否投资", index = 28)
    @Column(columnDefinition = "bool default false")
    open var invested: Boolean? = null

    // 基金的投资策略编号
    @ExcelIgnore
    @Column(columnDefinition = "varchar(50) default ''")
    open var fundCode: String? = null
}
